<?php
/**
 * GioCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@ninhgio.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2010-2011 GioCMS (http://cms.ninhgio.com)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @author		NinhGio - ninhgio@gmail.com
 * @since		1.0
 * @version		$Id:$
 */

$this->headTitle($this->TRANSLATOR->translator('page_add_page_title') . ' - ' . $this->TRANSLATOR->translator('common_admin_title'));
?>
<div class="content">
	<div class="box header mb0">
		<div class="head"><div></div></div>
		<h2 class="g_a_breadcump">
			<a class="fl" href="<?php echo $this->url('core_dashboard_index'); ?>"><?php echo $this->TRANSLATOR->translator('dashboard_breadcump'); ?></a>
			<small class="icon arrow_right" style="display: block;"></small>
			<a class="fl" href="<?php echo $this->url('core_page_list', array('template_id' => $this->template)); ?>"><?php echo $this->TRANSLATOR->translator('page_breadcump'); ?></a>
			<small class="icon arrow_right" style="display: block;"></small>
			<a class="fl" href="javascript: void(0);"><?php echo $this->TRANSLATOR->translator('page_add_breadcump'); ?></a>
			<div class="clear"></div>
		</h2>
	</div>
</div>
<div class="content">
	<div class="desc">
		<div class="body">
			<!--  -->
			<form action="<?php echo $this->url('core_page_add', array('template_id' => $this->template)); ?>" method="post" id="corePageAdd">
				<h4 class="g_a_h4 fl"><?php echo $this->TRANSLATOR->translator('page_add_guide'); ?></h4>
				<div class="fr">
					<?php if ($this->ACL->isAllowed('add', 'page', 'core')) : ?>
					<a class="fl g_a_tip form_submit g_a_submit_button mr5" href="javascript: void(0);" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('page_button_save_title')); ?>"></a>
					<?php endif; ?>
					<a class="fl g_a_tip g_a_cancel_button mr5" href="javascript: history.go(-1);" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('common_back_button', 'core')); ?>"></a>
					<?php if ($this->ACL->isAllowed('list', 'page', 'core')) : ?>
					<a class="fl g_a_tip" href="<?php echo $this->url('core_page_list', array('template_id' => $this->template)); ?>" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('page_actions_list_title')); ?>">
						<img src="<?php echo $this->APP_RESOURCE_SERVER; ?>/templates/<?php echo $this->APP_TEMPLATE; ?>/skins/<?php echo $this->APP_SKIN; ?>/images/actions_add_icon.png" style="padding: 0 5px 0 0;" />
					</a>
					<?php endif; ?>
				</div>
				<div class="g_a_line"></div>
				<p>
					<label for="simple_input"><?php echo $this->TRANSLATOR->translator('page_name'); ?></label>
					<input title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('page_name_description')); ?>" type="text" class="text w_20 g_a_tip_right" name="page[name]" id="name" value="<?php if (isset($this->pageData['name'])) : ?><?php echo $this->pageData['name']; ?><?php endif; ?>" />
					<?php if (isset($this->errorMessages) && isset($this->errorMessages['name'])) : ?>
					<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['name']); ?></span>
					<?php endif; ?>
					<br>
				</p>
				<p class="small">&nbsp;</p>
				<p>
					<label for="simple_input"><?php echo $this->TRANSLATOR->translator('page_description'); ?></label>
					<input title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('page_description_description')); ?>" type="text" class="text w_20 g_a_tip_right" name="page[description]" id="description" value="<?php if (isset($this->pageData['description'])) : ?><?php echo $this->pageData['description']; ?><?php endif; ?>" />
					<?php if (isset($this->errorMessages) && isset($this->errorMessages['description'])) : ?>
					<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['description']); ?></span>
					<?php endif; ?>
					<br>
				</p>
				<p class="small">&nbsp;</p>
				<p>
					<label for="simple_input"><?php echo $this->TRANSLATOR->translator('page_route'); ?></label>
					<select class="g_a_tip_right" id="route" name="page[route]" title="<?php echo $this->STRING->escape($this->TRANSLATOR->translator('page_route_description')); ?>">
						<option value=""><?php echo $this->TRANSLATOR->translator('common_select_option'); ?></option>
						<?php if (isset($this->routesFrontend) && $this->routesFrontend) : ?>
						<?php foreach ($this->routesFrontend as $index => $route) : ?>
						<option value="<?php echo $route['name']; ?>"<?php if (in_array($route['name'], $this->dbRoutesPage)) : ?> class="disabled" disabled="disabled"<?php endif; ?>><?php echo $this->TRANSLATOR->translator((isset($route['langKey'])) ? $route['langKey'] : null, $route['module']); ?></option>
						<?php endforeach; ?>
						<?php endif; ?>
					</select>
					<?php if (isset($this->errorMessages) && isset($this->errorMessages['route'])) : ?>
					<span class="g_a_error"><?php echo $this->TRANSLATOR->translator($this->errorMessages['route']); ?></span>
					<?php endif; ?>
					<br>
				</p>
				<p class="small">&nbsp;</p>
				
				<p class="last buttons_demo">
					<?php if ($this->ACL->isAllowed('add', 'page', 'core')) : ?>
					<a class="button form_submit green" href="<?php echo $this->url('core_page_add'); ?>"><small class="icon check"></small><span><?php echo $this->TRANSLATOR->translator('common_submit_button'); ?></span></a>
					<?php endif; ?>
					<a class="button red" href="javascript: history.go(-1);"><small class="icon cross"></small><span><?php echo $this->TRANSLATOR->translator('common_back_button'); ?></span></a>
					<?php if (isset($this->tokenElement)) : ?><?php echo $this->tokenElement; ?><?php endif; ?>
				</p>
			</form>
			<!--  -->
			<div class="clear"></div>
		</div>
	</div>
	<div class="body_footer">
		<div class="bottom_left"><div class="bottom_right"></div></div>
	</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$('#route').bind('change', function() {
		var text = $("#route option:selected").text();
		if (this.value != '') {
			$('#name').val(text);
			$('#description').val(text);	
		}
	});
	<?php if (($string = $this->MESSENGER->printMessages()) != null) : ?>
	Gio.Message.success('<?php echo $string; ?>');
	<?php endif; ?>
});
</script>